//
//  ModuleView.m
//  CocoaSynth
//
//  Created by Thomas Dupont on 19/02/10.
//  Copyright 2010 Apple Inc. All rights reserved.
//

#import "ModuleView.h"

#import "ModuleViewController.h"

@implementation ModuleView

@synthesize controller;
@synthesize highlight;

- (void)mouseDown:(NSEvent *)theEvent
{
	mouseDownPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
	[controller bringModuleToFront];
	[controller displayParameterView];
}

- (void)mouseDragged:(NSEvent *)theEvent
{
	NSPoint point = [theEvent locationInWindow];
	point = [self.superview convertPoint:point fromView:nil];
	
	NSRect rect;
	rect.origin.x = point.x - mouseDownPoint.x;
	rect.origin.y = point.y - mouseDownPoint.y;
	rect.size.width = self.frame.size.width;
	rect.size.height = self.frame.size.height;
	
	[self setFrame:rect];
	[self setNeedsDisplay:YES];
	[controller refresh];
}

- (void)rightMouseUp:(NSEvent *)theEvent
{
	[controller deleteModule];
}

@end
